<?php
declare (strict_types=1);

namespace app\validate;

use think\Validate;

class ShopValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'shop_name' => 'require',
        'username' => 'require',
        'mobile' => 'require|mobile',
        'address' => 'require',
        'business_img' => 'require',
        'logo' => 'require',
        'frontal_photo' => 'require',
        'backside_photo' => 'require',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'shop_name.require' => '门店名称不能为空',
        'username.require' => '负责人姓名不能为空',
        'mobile.require' => '手机号不能为空',
        'mobile.mobile' => '手机号格式错误',
        'address.require' => '商家地址不能为空',
        'business_img.require' => '营业执照不能为空',
        'logo.require' => '商家LOGO不能为空',
        'frontal_photo.require' => '法人身份证正面照不能为空',
        'backside_photo.require' => '法人身份证背面照不能为空',
    ];


    // edit 验证场景定义
    public function sceneEdit()
    {
        return $this->remove('id', 'require');
    }
}
